﻿using Abp.AutoMapper;
using GN.Pay.Core.Entities;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace GN.Pay.Application.GatewayApp.Dto.Output
{
    /// <summary>
    /// 支付申请输出
    /// </summary>
    [AutoMap(typeof(TradePayApply))]
    public class PayApplyOutput
    {
        /// <summary>
        /// 申请Id
        /// </summary>
        public string ApplyId { get; set; }

        /// <summary>
        /// 申请时间
        /// </summary>
        public DateTime ApplyTime { get; set; }

        //订单号      
        public string OrderNo { get; set; }

        //订单时间
        public DateTime OrderTime { get; set; }

        //订单金额
        public decimal OrderMoney { get; set; }

        /// <summary>
        /// 会员编号
        /// </summary>
        public string MemberNo { get; set; }

        /// <summary>
        /// 获取或设置用户标识(如微信 openId等)
        /// </summary>    
        [MaxLength(255, ErrorMessage = "用户标识不能超过 255 位的长度 ")]
        public string UserToken { get; set; }

        //商品标题      
        public string Subject { get; set; }

        //商品详情       
        public string Body { get; set; }

        //订单备注
        public string Remark { get; set; }

        //过期分钟       
        public int ExpireMinute { get; set; }

        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        public string ExpireMessage
        {
            get
            {
                string diff = "24小时";
                if (this.ExpireMinute <= 0)
                {
                    diff = "24小时";
                }
                else if (this.ExpireMinute <= 60)
                {
                    diff = ExpireMinute.ToString() + "分钟";
                }
                else
                {
                    if (ExpireMinute % 60 == 0)
                    {
                        diff = ExpireMinute / 60 + "小时";
                    }
                    else
                    {
                        diff = ((double)ExpireMinute / (double)60).ToString("N2") + "小时";
                    }
                }               
                return string.Format("请在{0}内支付，逾期自动取消", diff);
            }

        }
    }
}
